package cn.ruituo.test;

import cn.ruituo.dao.StudentDao;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

/**
 * @author oldliu
 * @since 1.0
 */
public class StudentDaoTest2 {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        //connection
        SqlSession session = sqlSessionFactory.openSession();
        StudentDao dao=session.getMapper(StudentDao.class);
        System.out.println(dao.getClass().getName());
        System.out.println("接口："+ Arrays.toString(dao.getClass().getInterfaces()));
        System.out.println("总数："+dao.findTotal());
        session.close();
    }
}
